/*
 * File Name: MessageHelper.java
 * Created on: September 25, 2007, 1:35 PM
 */

package co.edu.uniandes.intercon.client.gui.util;

import javax.swing.JOptionPane;

/**
 * <tt>MessageBox</tt> utility class
 * 
 * @author Fabian Gutierrez [fagossa@gmail.com]
 * @see JOptionPane
 */
public class MessageHelper {
    
    /*
     * Message shown in the confirmation window
     */
    private static String CONFIRMATION_TITLE = "Confirmation";
    
    /*
     * Message shown in the error window
     */
    private static String ERROR_TITLE = "Error";
    
    /*
     * Message shown in the data request window
     */
    private static String DATA_REQUEST_TITLE = "Data Request";
    
    // avoids instantiation
    private MessageHelper(){}
    
    /**
     * Shows a Error Dialog
     * @param   message Message to be shown in the dialog
     * @return  Data entered by the user
     */
    public static String showInputDialog(String message) {
        return JOptionPane.showInputDialog(null, message, DATA_REQUEST_TITLE,
                JOptionPane.INFORMATION_MESSAGE);
    }
    
    /**
     * Shows a Error Dialog
     * @param   message Message to be shown in the dialog
     */
    public static void showErrorDialog(String message) {
        JOptionPane.showMessageDialog(null, message, ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
    }
    
    /**
     * Shows a Sucess Dialog
     * @param   message Message to be shown in the dialog
     */
    public static void showSucessDialog(String message) {
        JOptionPane.showMessageDialog(null, message);
    }
    
    /**
     * Shows a Warning Dialog
     * @param   message Message to be shown in the dialog
     */
    public static void showWarningDialog(String message) {
        JOptionPane.showMessageDialog(null, message, ERROR_TITLE,
                JOptionPane.WARNING_MESSAGE);
    }
    
    /**
     * Shows a Confirmation Dialog
     * @param   message Message to be shown in the dialog
     * @return  Value representing the button pressed by the user. This values 
     *          are stored in the class {@link JOptionPane}
     * 
     * @see JOptionPane#CANCEL_OPTION
     * @see JOptionPane#DEFAULT_OPTION
     * @see JOptionPane#OK_CANCEL_OPTION
     * @see JOptionPane#YES_NO_OPTION
     */
    public static int showConfirmationDialog(String message) {        
        return JOptionPane.showConfirmDialog(null, message, CONFIRMATION_TITLE,
                JOptionPane.YES_NO_OPTION);
    }
    
}
